using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XEntity.InventoryItemSystem;

namespace XEntity.InventoryItemSystem
{
public class FastBarSelectBox : MonoBehaviour
{

    public ItemSlot[] itemSlots;
    public GameObject selectedBox;

    [Header("运行时")]
    public ItemSlot selectedItemSlot;
    
    private void Start() {
        ChangeSelectedItemSlot(0);
    }

    private void Update() {
        for (int i=0;i<itemSlots.Length;i++){
            if (Input.GetKeyDown(InteractionSettings.Current.fastBarKeys[i])){
                ChangeSelectedItemSlot(i);
            }
        }
        if (Input.GetKeyDown(InteractionSettings.Current.fastBarUseKey)){
            ItemManager.Instance.UseItem(selectedItemSlot);
        }

    }

    private void ChangeSelectedItemSlot(int idx){
        selectedItemSlot = itemSlots[idx];
        selectedBox.transform.position = selectedItemSlot.transform.position;
    }
}
}